package com.wx.controller;

import com.github.pagehelper.PageInfo;
import com.wx.entity.Student;
import com.wx.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.stereotype.Controller;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller

public class StudentController {
    @Autowired
    private StudentService studentService;
    @RequestMapping("/test")
    @ResponseBody
    public String getTest(){
        return "HELLOWORLD";
    }
    @RequestMapping("data")
    @ResponseBody
    public List getAll(){
        List<Student> all = studentService.findAll();
        return all;
    }

    @RequestMapping("add")
    @ResponseBody
    public String add( Student student){
        studentService.add(student);
        return  "成功";
    }
    @RequestMapping("/page")
    @ResponseBody
    public PageInfo findAll(){
        PageInfo byPage = studentService.findByPage();
        return byPage;
    }
    @RequestMapping("/excp")
    @ResponseBody
    public String exceptionTest(){
        throw  new RuntimeException("异常测试");
    }
}
